package com.cbd.pojo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.Valid;

import org.hibernate.annotations.ForeignKey;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.validation.annotation.Validated;

/**
 * 抢租客
 * 
 */
@Entity
@Table(name = "renter")
@Validated
public class Renter implements Serializable {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "renterID")
	private int renterID;
	/**
	 * 租客真实姓名
	 * 
	 */
	@Column(name = "renterName")
	@NotEmpty(message = "不能为空")
	@Length(max = 8, min = 2, message = "长度必须为2-8位")
	private String renterName;
	/**
	 * 租客电话 11位
	 * 
	 */
	@Column(name = "renterTel")
	@NotEmpty(message = "不能为空")
	@Length(min = 11, max = 11, message = "长度必须为11位")
	private String renterTel;
	/**
	 * 租客身份证号 18位
	 * 
	 */
	@Column(name = "renterCard")
	@NotEmpty(message = "不能为空")
	@Length(max = 18, min = 18, message = "长度必须为18位")
	private String renterCard;
	/**
	 * 家庭地址
	 */
	@Column(name = "renterAddress")
	@NotEmpty(message = "不能为空")
	@Length(max = 20, min = 3, message = "长度必须为3-20位") // 全中文
	private String renterAddress;
	/**
	 * 职业描述
	 */
	@Column(name = "renterDescribe")
	@NotEmpty(message = "不能为空")
	@Length(max = 20, min = 3, message = "长度必须为3-20位")
	private String renterDescribe;
	/**
	 * 租客 信誉度 格式m/n m:被投诉的次数 n:租车位次数
	 */
	@Column(name = "renterRP")
	private String renterRP;
	/**
	 * 租客注册时间
	 * 
	 */
	@Column(name = "renterTime")
	private Date renterTime;

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "renter")
	private List<Purpose> purposes;

	@OneToOne(cascade = CascadeType.ALL,fetch=FetchType.EAGER)
	@JoinColumn(name = "userID")
	private User user;

	public int getRenterID() {
		return renterID;
	}

	public void setRenterID(int renterID) {
		this.renterID = renterID;
	}

	public String getRenterName() {
		return renterName;
	}

	public void setRenterName(String renterName) {
		this.renterName = renterName;
	}

	public String getRenterTel() {
		return renterTel;
	}

	public void setRenterTel(String renterTel) {
		this.renterTel = renterTel;
	}

	public String getRenterCard() {
		return renterCard;
	}

	public void setRenterCard(String renterCard) {
		this.renterCard = renterCard;
	}

	public String getRenterAddress() {
		return renterAddress;
	}

	public void setRenterAddress(String renterAddress) {
		this.renterAddress = renterAddress;
	}

	public String getRenterDescribe() {
		return renterDescribe;
	}

	public void setRenterDescribe(String renterDescribe) {
		this.renterDescribe = renterDescribe;
	}

	public String getRenterRP() {
		return renterRP;
	}

	public void setRenterRP(String renterRP) {
		this.renterRP = renterRP;
	}

	public Date getRenterTime() {
		return renterTime;
	}

	public void setRenterTime(Date renterTime) {
		this.renterTime = renterTime;
	}

	public List<Purpose> getPurposes() {
		return purposes;
	}

	public void setPurposes(List<Purpose> purposes) {
		this.purposes = purposes;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}